package
{
	import flash.display.Shape;
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.geom.Point;
	
	public class PhysicalEquation extends Sprite
	{
		private var dx:Number = 0;
		private var dy:Number = 0;
		private var radiusX:Number = 120;
		private var radiusY:Number = 80;
		private var angle:Number = 0;
		
		public function PhysicalEquation()
		{
			AListenerEvent();
		}
		
		private function AListenerEvent():void
		{
			addEventListener(Event.FRAME_CONSTRUCTED, CreateShape);
		}
		
		private function CreateShape(e:Event):void
		{
			dx = 200 + Math.cos(angle) * radiusX;
			dy = 200 + Math.sin(angle) * radiusY;
			angle += 1;
			var npoint:Shape = new Shape();
			
			npoint.graphics.beginFill(0xff0000);
			npoint.graphics.drawCircle(dx,dy,5);
			npoint.graphics.endFill();
			addChild(npoint); 
			
			npoint.addEventListener(Event.FRAME_CONSTRUCTED, CreateSprite);
			if(angle > 3600)
			{
				trace("out");
				removeEventListener(Event.FRAME_CONSTRUCTED, CreateShape);
			}
		}
		
		private function CreateSprite(e:Event):void
		{
			var npoint:Shape = e.target as Shape;
			var dy2:Number = npoint.y - 20;
			
			var vy:Number = 0;
			
			if (npoint.y >= 200)
				vy += dy2 * 0.1;
			else if (npoint.y < 200 )
				vy -= dy2 * 0.1;
			
			npoint.y += vy;
		}
	}
}